#pragma once


#include "QuestionWindow.h"
// CFillingWindow dialog
#include "Core\QuestionAndAnswer.h"

#include <vector>
#include <map>

class CFillingWindow : public CQuestionWindow
{
    DECLARE_DYNAMIC(CFillingWindow)

public:
    CFillingWindow(CWnd* pParent = NULL);   // standard constructor
    virtual ~CFillingWindow();

// Dialog Data
    enum { IDD = IDD_FillingQuestion };

protected:
    std::vector<ExamSystem::CFillingQuestion> m_questions;
    std::vector<ExamSystem::CFillingAnswer> m_answers;

    std::vector<CString> m_answerStrings;
    std::vector<int> m_answerPos;
    std::map<int, int> m_answerIdxRange;
    std::vector<int> m_answerIdxBase;

    CString m_blank;
    CString m_replacer;
    CEdit m_editAnswer;
    CRichEditCtrl m_editQuestion;
    int m_editingIndex;

    int m_nLineCount;

protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL OnInitDialog();
protected:
    virtual void OnOK();
    virtual void OnCancel();
    void SetRichEditText(const CString &str);
    void TokenizeTitle(const CString &str, std::vector<CString> &texts);
    void ResizeWindow(void);
    BOOL PreTranslateMessage(MSG* pMsg);

public:
    virtual void ShowQuestion(void);
    virtual void SaveAndHide(void);
    virtual void Initialize(void);
    afx_msg void OnEnLinkRicheditQuestion(NMHDR *pNMHDR, LRESULT *pResult);
    afx_msg void OnEnChangeEditAnswer();
    afx_msg void OnEnKillfocusEditAnswer();
};
